From fa6adedc42e9c6ec39cc30df16b54900c220b094 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Mon, 20 Dec 2021 00:15:20 +0100
Subject: refactor: rewrite types and services

I was repeating myself a lot in services. So I rewrited the different
functions to improve readability and I extracted some formatting
functions to put them in utils. I also rewrited/reorganized some types
to keep consistent names.
---
 src/pages/sujet/[slug].tsx | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

(limited to 'src/pages/sujet/[slug].tsx')

diff --git a/src/pages/sujet/[slug].tsx b/src/pages/sujet/[slug].tsx
index a6acf2b..4dc4e9b 100644
--- a/src/pages/sujet/[slug].tsx
+++ b/src/pages/sujet/[slug].tsx
@@ -1,10 +1,6 @@
 import Layout from '@components/Layouts/Layout';
 import PostPreview from '@components/PostPreview/PostPreview';
 import { t } from '@lingui/macro';
-import {
-  fetchAllSubjectsSlug,
-  getSubjectBySlug,
-} from '@services/graphql/taxonomies';
 import { NextPageWithLayout } from '@ts/types/app';
 import { SubjectProps } from '@ts/types/taxonomies';
 import { loadTranslation } from '@utils/helpers/i18n';
@@ -13,6 +9,10 @@ import Image from 'next/image';
 import { ParsedUrlQuery } from 'querystring';
 import { ReactElement } from 'react';
 import styles from '@styles/pages/Subject.module.scss';
+import {
+  getAllSubjectsSlug,
+  getSubjectBySlug,
+} from '@services/graphql/queries';
 
 const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => {
   const getPostsList = () => {
@@ -68,7 +68,6 @@ interface PostParams extends ParsedUrlQuery {
 export const getStaticProps: GetStaticProps = async (
   context: GetStaticPropsContext
 ) => {
-  console.log(context);
   const translation = await loadTranslation(
     context.locale!,
     process.env.NODE_ENV === 'production'
@@ -85,7 +84,7 @@ export const getStaticProps: GetStaticProps = async (
 };
 
 export const getStaticPaths: GetStaticPaths = async () => {
-  const allSlugs = await fetchAllSubjectsSlug();
+  const allSlugs = await getAllSubjectsSlug();
 
   return {
     paths: allSlugs.map((post) => `/sujet/${post.slug}`),
-- 
cgit v1.2.3

